package com.drojian.singleton.type7;

import org.junit.Test;
/**
 * 使用枚举实现单例模式
 */
public class SingletonTest07 {
    @Test
    public void test01(){
        Singleton singleton1 = Singleton.INSTANCE;
        Singleton singleton2 = Singleton.INSTANCE;
        System.out.println(singleton1 == singleton2);
        System.out.println(singleton1.hashCode());
        System.out.println(singleton2.hashCode());

    }
}
enum Singleton{
    INSTANCE;
    public void sayOK(){
        System.out.println("hello");
    }

}